package com.example.demo.user.service.impl;

import com.example.demo.user.dao.UserMapper;
import com.example.demo.user.entity.User;
import com.example.demo.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    @Override
    public List<User> findList(User user) {
        List<User> list = userMapper.findList(user);
        return list;
    }

    /**
     * 查询一个用户
     * @param id
     * @返回值 User 用户对象
     */
    @Override
    public User findOne(String id) {
        User user = userMapper.selectByPrimaryKey(id);
        return user;
    }

    /**
     * 删除用户
     * @param id
     */
    @Override
    public void remove(String id) {

        userMapper.deleteByPrimaryKey(id);
    }

    /**
     * 新增用户
     * @param user
     * 返回值 无用void
     */
    @Override
    public void save(User user) {
          userMapper.insertSelective(user);
    }

    /**
     * 修改用户
     * @param user
     */
    @Override
    public void update(User user) {
        userMapper.updateByPrimaryKey(user);
    }
}
